<?php


namespace App\Models\Admin;


use App\Log\AdminSettingLog;

class AdminSetting extends Base
{
    const OPERATE_PID = 3;
    const MODEL = 'admin_setting';
    protected $table = 'admin_setting';
    protected $guarded = [];
    public $timestamps = false;

    public static function addLog($pre,$next,$type,$method='')
    {
        $info = AdminOperateModule::where('pid',self::OPERATE_PID)->where('type',$type)->where('model',self::MODEL)->when($method,function ($query)use ($method){
            $query->where('method',$method);
        })->first();
        if (!empty($info)){
            $adminLog = new AdminSettingLog($pre,$next,$info);
            $adminLog->addLog();
        }
    }

    public static function getField($field='')
    {
        if (empty($field)) return '';
        return self::where('name',$field)->first()->value('value');
    }
}
